﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BusinessLoginLayer
{
    public partial class Company_Details
    {
        public static bool ValidadeToken(string token)
        {
            using (PlanesManagerEntity entity = new PlanesManagerEntity())
                return entity.Company_Details.Where(i => i.AcessToken == token && i.IsActive).Any();
        }

        public static CommonClasses.CompanyDetails GetClientInfo(string token)
        {
            using (PlanesManagerEntity entity = new PlanesManagerEntity())
            {
                return (from ent in entity.Company_Details
                        where ent.AcessToken == token
                        && ent.IsActive
                        select new CommonClasses.CompanyDetails()
                        {
                            Email = ent.Email,
                            Name = ent.Name
                        }).FirstOrDefault();
            }
                
        }
    }
}
